﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Imaging;
using System.IO;
using System.Windows;

namespace QuickTweet.Common
{
    public static class Shell
    {
        public static BitmapImage GetImage(this Application application, string file)
        {
            var uri = new Uri(string.Format("pack://application:,,,/{0}", file));
            return new BitmapImage(uri);
        }

        public static BitmapImage GetImage(this Application application, string assembly, string file)
        {
            var uri = new Uri(string.Format("pack://application:,,,/{0};component/{1}", assembly, file));
            return new BitmapImage(uri);
        }

        public static Stream GetResourceStream(this Application application, string file)
        {
            var uri = new Uri(string.Format("pack://application:,,,/{0}", file));
            var sri = Application.GetResourceStream(uri);
            if (sri != null)
                return sri.Stream;

            return null;
        }

        public static Stream GetResourceStream(this Application application, string assembly, string file)
        {
            var uri = new Uri(string.Format("pack://application:,,,/{0};component/{1}", assembly, file));
            var sri = Application.GetResourceStream(uri);
            if (sri != null)
                return sri.Stream;
            return null;
        }
    }
}
